<?php

namespace IDock\Insurance\AMIC\Response;

use IDock\Http\Response;
use IDock\Insurance\AMIC\Response\AllAMICResponse;
use IDock\Printer\NonCar\NonCarProductListPrinter;
use IDock\Printer\NonCar\NonCarProductPrinter;
use IDock\Printer\NonCar\NonCarSubCoveragePrinter;
use IDock\Printer\UnderwritingRecallPrinter;

class NonCarProductListResponse extends AllAMICResponse
{

    public $seat = 5;
    public function printerInit(): Response
    {
        $printer = new NonCarProductListPrinter();

        $list = [
            [
                'productCode' => '20170514A1',
                'productName' => '驾乘安心 A-1款',
                'planCode' => '20170514A1',
                'planName' => '驾乘安心 A-1款',
                'premium' => '150',
                'maxLimit' => '1',
                'coverageList' => [
                    [
                        'subCode' => '',
                        'subName' => '意外身故、残疾',
                        'amount' => '100000',
                        'premium' => '105.00',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '意外伤害医疗',
                        'amount' => '10000',
                        'premium' => '20.00',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '意外伤害住院津贴',
                        'amount' => '5400',
                        'premium' => '25',
                    ],
                ],
            ],
            [
                'productCode' => '20170514A2',
                'productName' => '驾乘安心 A-2款',
                'planCode' => '20170514A2',
                'planName' => '驾乘安心 A-2款',
                'premium' => '200',
                'maxLimit' => '1',
                'coverageList' => [
                    [
                        'subCode' => '',
                        'subName' => '意外身故、残疾',
                        'amount' => '100000',
                        'premium' => '140.00',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '意外伤害医疗',
                        'amount' => '10000',
                        'premium' => '30.00',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '意外伤害住院津贴',
                        'amount' => '5400',
                        'premium' => '30',
                    ],
                ],
            ],
            [
                'productCode' => '20170514B1',
                'productName' => '驾乘安心B-1款',
                'planCode' => '20170514B1',
                'planName' => '驾乘安心B-1款',
                'premium' => '200',
                'maxLimit' => '1',
                'coverageList' => [
                    [
                        'subCode' => '',
                        'subName' => '意外身故、残疾',
                        'amount' => '100000',
                        'premium' => '105.00',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '意外伤害医疗',
                        'amount' => '10000',
                        'premium' => '20.00',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '意外伤害住院津贴',
                        'amount' => '9000',
                        'premium' => '40',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '节假日及双休日意外伤害',
                        'amount' => '100000',
                        'premium' => '35',
                    ],
                ],
            ],
            [
                'productCode' => '20170514B2',
                'productName' => '驾乘安心B-2款',
                'planCode' => '20170514B2',
                'planName' => '驾乘安心B-2款',
                'premium' => '280',
                'maxLimit' => '1',
                'coverageList' => [
                    [
                        'subCode' => '',
                        'subName' => '意外身故、残疾',
                        'amount' => '100000',
                        'premium' => '140.00',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '意外伤害医疗',
                        'amount' => '10000',
                        'premium' => '30.00',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '意外伤害住院津贴',
                        'amount' => '9000',
                        'premium' => '55',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '节假日及双休日意外伤害',
                        'amount' => '100000',
                        'premium' => '55',
                    ],
                ],
            ],
            [
                'productCode' => '20170514C1',
                'productName' => '驾乘安心C-1款',
                'planCode' => '20170514C1',
                'planName' => '驾乘安心C-1款',
                'premium' => '365',
                'maxLimit' => '1',
                'coverageList' => [
                    [
                        'subCode' => '',
                        'subName' => '意外身故、残疾',
                        'amount' => '200000',
                        'premium' => '210.00',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '意外伤害医疗',
                        'amount' => '20000',
                        'premium' => '45.00',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '意外伤害住院津贴',
                        'amount' => '36000',
                        'premium' => '110',
                    ],
                ],
            ],
            [
                'productCode' => '20170514C2',
                'productName' => '驾乘安心C-2款',
                'planCode' => '20170514C2',
                'planName' => '驾乘安心C-2款',
                'premium' => '455',
                'maxLimit' => '1',
                'coverageList' => [
                    [
                        'subCode' => '',
                        'subName' => '意外身故、残疾',
                        'amount' => '200000',
                        'premium' => '260.00',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '意外伤害医疗',
                        'amount' => '20000',
                        'premium' => '60.00',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '意外伤害住院津贴',
                        'amount' => '36000',
                        'premium' => '135',
                    ],
                ],
            ],
        ];

        foreach ($list as $item) {
            $amount = 0;
            $productPrinter = new NonCarProductPrinter();
            $productPrinter->productCode = $item['productCode'] ?? '';//产品编码
            $productPrinter->productName = $item['productName'] ?? '';//产品名称
            $productPrinter->productType = '驾意险';
            $productPrinter->productDesc = '';
            $productPrinter->planCode = $item['planCode'] ?? '';//方案代码
            $productPrinter->planName = $item['planName'] ?? '';//方案名称
            $productPrinter->maxQuantity = $item['maxLimit'];//最大购买份数
            foreach ($item['coverageList'] ?? [] as $sub) {
                $subCoverage = new NonCarSubCoveragePrinter();
                $subCoverage->subCode = $sub['subCode'] ?? '';
                $subCoverage->subName = $sub['subName'] ?? '';
                $subCoverage->amount = $sub['amount'] ?? '';
                $amount += $subCoverage->amount;
                $productPrinter->subCoverageAppend($subCoverage);
            }
            $productPrinter->premium = $item['premium'];
            $productPrinter->unitAmount = $amount;
            $productPrinter->argc['amount'] = $amount;
            $productPrinter->argc['productName'] = $item['productName'] ?? '';//产品名称

            $printer->productListAppend($productPrinter);
        }


        $this->printer = $printer;
        return $this;
    }
}
